import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const UserInfo = 'userInfo'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function setUserInfo(userInfo) {
  console.log('set--',userInfo)
  return Cookies.set(UserInfo, userInfo)
}
export function getUserInfo() {
  let val = Cookies.get(UserInfo);
  if (typeof val === 'undefined') {
    // 去登录
  }else if (typeof val === 'string') {
    val = JSON.parse(val)
  }
  console.log('get--',val)
  return val
}